package exercises.leetcode;

import java.util.Arrays;
import java.util.Scanner;

/**
 * <a href="">
 * </a>
 *
 * <p><span color="#87CEEB">描述:</span>
 *
 * @author or2
 * @date 2021年10月24日 时间: 10:52
 */
public class Saike_01_C {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt(), m = scanner.nextInt();
        int[][] points_n = new int[4][2];
        int[] temp = new int[4];
        findBOUND(scanner, n, points_n, temp);
        int[][] points_m = new int[4][2];
        findBOUND(scanner, m, points_m, temp);

        if (points_n[0][1] < points_m[1][1] && points_n[0][0] < points_m[3][0]
                && points_n[2][1] > points_m[3][1] && points_n[2][0] > points_m[1][0]) {
            System.out.println("YES");
            return;
        }
        if (points_m[0][1] < points_n[1][1] && points_m[0][0] < points_n[3][0]
                && points_m[2][1] > points_n[3][1] && points_m[2][0] > points_n[1][0]) {
            System.out.println("YES");
            return;
        }
        System.out.println("NO");
    }

    private static void findBOUND(Scanner scanner, int n, int[][] points_n, int[] temp) {
        Arrays.fill(temp, Integer.MAX_VALUE);
        for (int i = 0; i < n; i++) {
            int x = scanner.nextInt(), y = scanner.nextInt();
            int manhadun = manhadun(x, y, 0, 0);
            if (manhadun < temp[0]) {
                points_n[0] = new int[]{x, y};
                temp[0] = manhadun;
            }
            manhadun = manhadun(x, y, 0, 1000_0000);
            if (manhadun < temp[1]) {
                points_n[1] = new int[]{x, y};
                temp[1] = manhadun;
            }
            manhadun = manhadun(x, y, 1000_0000, 1000_0000);
            if (manhadun < temp[2]) {
                points_n[2] = new int[]{x, y};
                temp[2] = manhadun;
            }
            manhadun = manhadun(x, y, 1000_0000, 0);
            if (manhadun < temp[3]) {
                points_n[3] = new int[]{x, y};
                temp[3] = manhadun;
            }
        }
    }

    private static final int manhadun(int x, int y, int dest_x, int dest_y) {
        return Math.abs(x - dest_x) + Math.abs(y - dest_y);
    }
}
